package com.tedu._05springmvc.controller;

import com.tedu._05springmvc.controller.pojo.dto.BmiDTO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class BmiController {
    @RequestMapping("Bmic")
    @ResponseBody
    public String bmi(BmiDTO bmidto){
        double height = bmidto.getHeight();
        System.out.println(height);
        double weight=bmidto.getWeight();
        System.out.println(weight);
        float bmi = (float)(weight/height/height);
        System.out.println(bmi);
        if(bmi<18.5){
            return bmi + "偏瘦";
        } else if (bmi>=27) {
            return bmi+"该减肥了";
        } else if (bmi>24&&bmi<27) {
            return bmi+"微胖";
        } else{
            return bmi + "正常";
        }
    }
}
